import Vue from 'Vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const heart = {
    state: {
        love: undefined
    },
    mutations: {
        love(state, target) {
            state.loves = target
        },
        unlove(state) {
            state.loves = undefined
        }
    }
}

var leftLobe = {
    namespaced: true,
    state: {
        reason: true
    },
    mutations: {
        toggle: state => { state.reason = !state.reason }
    },
    actions: {
        beNerd: context => { context.rootState.heart.loves = 'Math & Physics' }
    }
}

var rightLobe = {
    namespaced: true,
    state: {
        fantasy: true
    },
    mutations: {
        toggle: state => { state.fantasy = !state.fantasy }
    }
}

const brain = {
    modules: {
        left: leftLobe,
        right: rightLobe
    }
}

const store = new Vuex.Store({
    modules: {
        heart,
        brain
    }
})

export default store